
#
# Builds freeGSD
# The ARCH, C_FLAGS, ASM_FLAGS, and LD_FLAGS variables are passed to make
# via the compile.sh script.

ARCH=
CC=gcc
ASM=yasm
LD=ld

INCLUDE=-I../include
OBJECTS=entrance.o kernel.o video.o inout.o gdt.o util.o mm.o klib.o

freeGSD: config.h $(OBJECTS)
	$(LD) $(LD_FLAGS) $(OBJECTS) -o freeGSD

### Object compilation

.c.o:
	$(CC) $(INCLUDE) $(C_FLAGS) $<

.s.o:
	$(ASM) $(ASM_FLAGS) $<

klib.o:
	cd klib && make

mm.o:
	cd mm && make

config.h:
	./genconfig.sh $(ARCH)

### cleaning targets

clean: clean-klib clean-mm
	rm -f *.o
	rm -f freeGSD
	rm -f kernel.map

dist-clean: clean-klib clean-mm
	rm -f ../include/config.h
	rm -f *.o
	rm -f freeGSD
	rm -f kernel.map

clean-klib:
	cd klib && make clean

clean-mm:
	cd mm && make clean
